package top.hidoctor.auscultation.adapter;

import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import top.hidoctor.auscultation.R;
import top.hidoctor.auscultation.bean.FileBean;

public class FileAdapter extends BaseQuickAdapter<FileBean> {
    public FileAdapter(int layoutResId, List<FileBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FileBean item) {
        TextView tvName = helper.getView(R.id.tv_name);
        helper.setText(R.id.tv_name, item.getTitle());

        Drawable leftDrawable = mContext.getResources().getDrawable(R.mipmap.wenjianjia);
        if (item.getCmdType().equals("b4")) {
            tvName.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, null, null, null);
        } else {
            Drawable rightdrawable1 = mContext.getResources().getDrawable(R.mipmap.ic_gou);
            Drawable rightdrawable2 = mContext.getResources().getDrawable(R.mipmap.ic_download);
            tvName.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, null, item.isDownload() ? rightdrawable1 : rightdrawable2, null);
        }
    }
}
